<?php
declare(strict_types=1);

namespace app\admin\validate;

use think\Validate;

class LoginValidate extends Validate
{
    protected $rule = [
        'username' => 'require|length:4,32',
        'password' => 'require|length:6,32',
        'captcha'  => 'require|length:4'
    ];

    protected $message = [
        'username.require' => '用户名不能为空',
        'username.length' => '用户名长度必须在4-32个字符之间',
        'password.require' => '密码不能为空',
        'password.length' => '密码长度必须在6-32个字符之间',
        'captcha.require' => '验证码不能为空',
        'captcha.length' => '验证码长度必须为4位'
    ];

    // 验证场景
    protected $scene = [
        'login' => ['username', 'password'],
        'login_captcha' => ['username', 'password', 'captcha']
    ];
} 